<template>
	<BasicModal v-bind="$attrs" z-index="1000" style="z-index:999" @register="registerModal" title="转入数据"
		:helpMessage="['提示', '先选择旅行社再导入']">
		<a-form-item label="" style="width: 300px;float:left;">
			<JSearchSelectTag placeholder="选择旅行社" v-model:value="selectValueExport"
				dict="couple_shop,title,id,shop_category=2" async>
			</JSearchSelectTag>
		</a-form-item>
		<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportClickXls"> 导出</a-button>
	</BasicModal>
</template>
<script lang="ts" setup>
	import AMapLoader from '@amap/amap-jsapi-loader';
	import { defineComponent, ref, unref, inject } from 'vue';
	import { coupleActivityOrderColumns } from '../activity/CoupleActivityCarpoolBus.data';
	import { coupleActivityOrderList, coupleActivityOrderDelete, coupleActivityOrderDeleteBatch, coupleActivityOrderExportXlsUrl, coupleActivityOrderImportUrl } from '../activity/CoupleActivityCarpoolBus.api';

	import { useMessage } from '/@/hooks/web/useMessage';
	import { BasicModal, useModalInner } from '/@/components/Modal';
	import { useListPage } from '/@/hooks/system/useListPage'
	import { isEmpty } from "/@/utils/is";
	import JSearchSelectTag from '/@/components/Form/src/jeecg/components/JSearchSelect.vue';
	const selectValueExport = ref('');
	let value = ref<string>('');
	const emit = defineEmits(['register', 'successConfirm']);
	const { createMessage } = useMessage();
	const loading = ref(false);
	const mainId = inject('mainId') || '';
	const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
		setModalProps({ zIndex: 1000 })
	})
	const onExportClickXls = () => {
		if (!isEmpty(unref(selectValueExport))) {
			loading.value = true;
			let returnVal = onExportXls()
			setTimeout(function () {
				closeModal()
				loading.value = false;
			}, 1000);
		} else {
			createMessage.error("请先选择需要转出到的旅行社")
		}
	}
	const { onExportXls } = useListPage({
		tableProps: {
			api: coupleActivityOrderList,
			columns: coupleActivityOrderColumns,
			canResize: false,
			useSearchForm: false,
			actionColumn: {
				width: 180,
				fixed: 'right',
			},
			pagination: {
				current: 1,
				pageSize: 5,
				pageSizeOptions: ['5', '10', '20'],
			},
		},
		exportConfig: {
			name: '订单管理',
			url: coupleActivityOrderExportXlsUrl,
			params: {
				'carpoolBus': mainId,
				'rollInShopId': selectValueExport
			}
		},
		importConfig: {
			url: () => {
				return coupleActivityOrderImportUrl + '/' + unref(mainId)
			}
		}
	});
</script>

<style>

</style>